<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>后台登录</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/static/adminlte/dist/css/AdminLTE.min.css">


</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="#"><b>NNCMS</a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">管理后台</p>

    <form id="LoginForm" action="{{ route('admin.login') }}" method="post">
      <div class="form-group has-feedback">
        <input type="text" name="username" class="form-control" placeholder="用户名">
        <span class="glyphicon glyphicon-user form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" name="password" class="form-control" placeholder="Password">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
			<div class="form-group">

        <div class="row" style="padding-right: 65px;">
            <div class="col-xs-8">
                <input style="width: 135px" type="text" name="verify" class="form-control" placeholder="验证码"/>
            </div>
            <div class="col-xs-4">
            		<img src="{{ url('/captcha') }}" onclick="this.src='{{ url('/captcha') }}?r='+Math.random();" alt="">
            </div>
        </div>

        </div>
     
      
			<div class="form-group">
				<input type="hidden" name="_token" value="{{csrf_token()}}">
  	 		<button type="submit" class="btn btn-primary btn-block btn-flat">立即登陆 </button>  
  		</div>  
    </form>
  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 2.2.3 -->
<script src="/static/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/adminlte/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/jquery-validation-1.15.1/jquery.validate.min.js"></script>
<script src="/static/jquery-validation-1.15.1/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(function(){
    $("#LoginForm").validate({
        submitHandler:function(){
			var LoginForm = $('#LoginForm');
	        $.ajax({
	            url: LoginForm.attr('action'),
	            type: LoginForm.attr('method'),
	            data: LoginForm.serialize(),
	            success: function (info) {
	                if (info.code === 1) {
	                    setTimeout(function () {
	                        location.href = info.url;
	                    }, 1000);
	                }
	                layer.msg(info.msg);
	            }
	        });		
        },    	
    	rules:{
    		username:'required',
    		password:'required',
    		verify:'required'
    	},
    	messages:{
    		username:'请输入名称',
    		password:'请输入密码',
    		verify:'请输入验证码'
    	},
		//重写showErrors
        showErrors: function (errorMap, errorList) {
	        $.each(errorList, function (i, v) {
	            //layer.tips(v.message, v.element, { time: 2000 });
	            layer.msg(v.message,function(){
	            	
	            });
	            return false;
	        });  
        },
        //失去焦点时不验证
        onfocusout: false

    });
	});
</script>
</body>
</html>
